<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" v-cloak>
    <el-row class="header navbar shadow">
<!--        &lt;!&ndash;搜索条件&ndash;&gt;-->
<!--        <div class="btn-group tool-button mt5">-->
<!--            <el-input placeholder="用户名或昵称或手机号" v-model="pageForm.searchKeyword" @keyup.enter.native="doSearch"-->
<!--                      size="medium"></el-input>-->
<!--        </div>-->
        <div class="btn-group tool-button mt5">
            <el-date-picker
                    v-model="searchDate"
                    type="daterange"
                    :picker-options="pickerOptions"
                    range-separator="至"
                    start-placeholder="开始日期"
                    end-placeholder="结束日期"
                    unlink-panels
                    align="right"
                    size="medium"
                    value-format="yyyy-MM-dd"
                    style="width: 400px">
            </el-date-picker>
        </div>
        <!--搜索按钮-->
        <div class="btn-group tool-button mt5">
            <el-button slot="append" icon="el-icon-search" @click="doSearch" size="medium"></el-button>
        </div>
    </el-row>
    <el-row class="el-table-container">
        <el-table
                :data="tableData"
                @sort-change='pageOrder'
                size="small"
                header-align="center"
                @selection-change="handleSelectionChange"
                style="width: 100%"
                :default-sort="{prop: 'opAt', order: 'descending'}">

            <el-table-column
                    width="140"
                    label="日期"
                    header-align="center"
                    align="center"
                    prop="date"
                    :show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column
                    width="140"
                    label="提现总额$"
                    header-align="center"
                    align="center"
                    prop="withdrawAmount"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="提现笔数"
                    header-align="center"
                    align="center"
                    prop="withdrawNum"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="提现撤销总额$"
                    header-align="center"
                    align="center"
                    prop="withdrawRejectAmount"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="提现撤销笔数"
                    header-align="center"
                    align="center"
                    prop="withdrawRejectNum"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="充值总额$"
                    header-align="center"
                    align="center"
                    prop="rechargeAmount"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="充值笔数"
                    header-align="center"
                    align="center"
                    prop="rechargeNum"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    width="140"
                    label="下级返佣总额$"
                    header-align="center"
                    align="center"
                    prop="subRebateAmount"
                    :sortable="'custom'"
                    :show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column
                    label="投资总人数"
                    header-align="center"
                    align="center"
                    prop="investPeopleNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="体验金投资人数"
                    header-align="center"
                    align="center"
                    prop="expInvestPeopleNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column
                    label="投资总额$"
                    header-align="center"
                    align="center"
                    prop="investAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column
                    label="投资笔数"
                    header-align="center"
                    align="center"
                    prop="investNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="撤销投资总额$"
                    header-align="center"
                    align="center"
                    prop="investRevertAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="撤销投资笔数"
                    header-align="center"
                    align="center"
                    prop="investRevertNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="投资本金收益总额$"
                    header-align="center"
                    align="center"
                    prop="investIncomeAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>



            <el-table-column
                    label="发送红包总额$"
                    header-align="center"
                    align="center"
                    prop="sendRedPacketAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="发送红包个数"
                    header-align="center"
                    align="center"
                    prop="sendRedPacketNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>


            <el-table-column
                    label="过期红包总额$"
                    header-align="center"
                    align="center"
                    prop="expiredRedPacketAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="过期红包个数"
                    header-align="center"
                    align="center"
                    prop="expiredRedPacketNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="收到红包总额$"
                    header-align="center"
                    align="center"
                    prop="receivedRedPacketAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="收到红包个数"
                    header-align="center"
                    align="center"
                    prop="receivedRedPacketNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="签到金币兑换总额$"
                    header-align="center"
                    align="center"
                    prop="ballCoinExchangeAmount"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="登录人数"
                    header-align="center"
                    align="center"
                    prop="loginNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    label="注册人数"
                    header-align="center"
                    align="center"
                    prop="registerNum"
                    :sortable="'custom'"
                    width="140"
                    :show-overflow-tooltip="true">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="创建时间"
                    header-align="center"
                    align="center"
                    prop="ctAt">
                <template slot-scope="scope">
                    {{formatAt(scope.row.ctAt)}}
                </template>
            </el-table-column>
        </el-table>
    </el-row>
    <el-row class="el-pagination-container">
        <el-pagination
                @size-change="pageSizeChange"
                @current-change="pageNumberChange"
                :current-page="pageForm.pageNumber"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageForm.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="pageForm.totalCount">
        </el-pagination>
    </el-row>
</div>
<script>
    new Vue({
        el: "#app",
        data: function () {
            return {
                searchDate: [],
                pickerOptions: {
                    shortcuts: [{
                        text: '最近一周',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-1, 'weeks').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近一个月',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-1, 'months').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }, {
                        text: '最近三个月',
                        onClick: function (picker) {
                            var end = new Date();
                            var start = new Date();
                            var temp = moment().add(-3, 'months').valueOf();
                            start.setTime(temp);
                            picker.$emit('pick', [start, end]);
                        }
                    }]
                },
                pageForm: {
                    userType: "",
                    searchKeyword: "",
                    searchDate: "",
                    pageNumber: 1,
                    pageSize: 10,
                    totalCount: 0,
                    pageOrderName: "",
                    pageOrderBy: ""
                },
                tableData: [],
                selectData: []
            }
        },
        methods: {
            pageOrder: function (column) {//按字段排序
                this.pageForm.pageOrderName = column.prop;
                if (column.order === "descending") {
                    this.pageForm.pageOrderBy = "DESC";
                } else {
                    this.pageForm.pageOrderBy = "ASC";
                }
                this.pageData();
            },
            pageNumberChange: function (val) {//页码更新操作
                this.pageForm.pageNumber = val;
                this.pageData();
            },
            pageSizeChange: function (val) {//分页大小更新操作
                this.pageForm.pageSize = val;
                this.pageData();
            },
            doSearch: function () {
                this.pageForm.pageNumber = 1;
                this.pageData();
            },
            pageData: function () {//加载分页数据
                let self = this;
                sublime.showLoadingbar();//显示loading
                if (self.searchDate) {
                    self.pageForm.searchDate = self.searchDate.toString();
                } else {
                    self.pageForm.searchDate = "";
                }
                $.post(base + "/platform/user/account/statistics/data", self.pageForm, function (data) {
                    sublime.closeLoadingbar();//关闭loading
                    if (data.code === 0) {
                        self.tableData = data.data.list;
                        self.pageForm.totalCount = data.data.totalCount;
                    } else {
                        self.$message({
                            message: data.msg,
                            type: 'error'
                        });
                    }
                }, "json");
            },
            formatAt: function (val) {
                if (val > 0)
                    return moment(val * 1000).format("YYYY-MM-DD HH:mm");
                return "";
            },
            handleSelectionChange: function (val) {
                this.selectData = val;
            },
        },
        created: function () {
            this.pageData();
        }
    });
</script>
<!--#
}
#-->